home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
FishMarket 1.0
/
FishMarket v1.0.iso
/
fishies
/
476-500
/
disk_499
/
matlab
/
matlab.lzh
/
plot.doc
< prev
next >
Wrap
Text File
|
1991-05-22
|
25KB
|
991 lines
C
MATLAB PLOTS
VERSION OF 20 JUNE 1989
Brought to you by:
Jim Locker
SofTech Inc.
4443 N. Hyland Ave.
Dayton Oh 45424
(513)-429-2771
TABLE OF CONTENTS
CHAPTER PAGE
1.0 Introduction 2
2.0 The Main Menu 3
3.0 3-D Plots 5
4.0 X-Y Plots 7
5.0 Polar Plots 10
6.0 Contour Plots 12
7.0 Histograms 13
8.0 Using Matlab as a Data Plotter 14
9.0 Demos 15
1.0 Introduction
Matlab Plot is a flexible and comprehensive plot package for Matlab. You
may have as many plots on one 16 color hi-res interlace screen as you
think you can make sense out of. You may save definitions for as many as
10 of those plots and may display those plots individually or
collectively. This manual describes the operation of the plot function
and some details about each choice. For more information on some of the
choices, you should consult the diglib manual.
To enter matlab plot, type "Plot(x);" from matlab, where x is any matrix.
This will enter the plot interactive mode. To enter batch mode, type
"Plot(x,'filename');" from matlab. In this mode, the filename is the
name of a previously saved plot definition file. In batch mode, plot
will automagically load the plot file and plot x according to the
definitions it finds there, without any other action on your part.
When entering Plot interactively from the CLI, you will first be asked if
you have set the stack up to at least 100K. Answer yes or no. If you
say yes when you should have said no, you will experience a spectacular
crash. If you say no, you will exit to Matlab. At this time, save your
work, exit Matlab, and set your stack. Then re-enter Matlab to do your
plots. A screen will be opened behind the Workbench screen. You should
click to and from this screen using the left-Amiga-M and -N options.
When a plot is active, the plot window will block the plot screen
front/back gadgets.
2.0 The Main Menu
After setting your stack and answering yes to the question, you will
reach the main menu. This menu says:
PLEASE SELECT AN OPTION:
1 3D PLOT
2 X-Y PLOT
3 POLAR PLOT
4 CONTOUR PLOT
5 HISTOGRAM
6 SET BACKGROUND COLOR
7 PLOT BUFFER CONTROL
8 READ PLOT FILE
9 END THE CURRENT PLOT
10 EXIT TO MATLAB
Options 1 through 5 will be discussed in the relevant sections of this
document.
If option 6 is selected, you will be prompted to enter a pen number.
Enter a number from 1 to 15. The plot background will be set to the
color you select. Sorry...you cannot preview the colors. At a later
point I will add that capability. For now, you should just experiment.
If you don't select a background color, the default is black. Color 1 is
white, color 2 is red, and so forth.
Option 8 will prompt you to enter a file name of a previously saved plot
definition file. Enter the file name, then sit back and watch. The file
will be loaded and the plots will be generated automatically.
Option 9 will end the current plot and the program will hang until you
click on the close gadget on the plot screen. You may click on the close
box at any time, and this release of Matlab will close the window the
next time it checks the Intuition message port, which it does frequently.
Option 10 exits Plot to matlab.
Option 7 is the Plot buffer control. The last 10 plot definitions are
stored in a buffer. This option controls how that buffer is handled.
When option 7 is selected, the following menu appears:
PLEASE CHOOSE THE PLOT BUFFER CONTROL OPTION:
1 CLEAR THE BUFFER
2 DELETE A PLOT
3 SHOW THE PLOT BUFFER
4 DISPLAY ONE OF THE SAVED PLOTS
5 DISPLAY ALL SAVED PLOTS
6 SAVE THE PLOT BUFFER
7 RETURN TO MAIN MENU
Choosing option 1 will clear the buffer and eliminate all plot
definitions. Choosing option 2 will display the contents of the buffer
and prompt you to enter a buffer number to delete. That buffer will be
deleted. The buffer handler does not fill holes in the buffer so, for
instance, if you delete plot 2 out of a three plot buffer, then define a
new plot, that new plot will appear as plot 4 and plot 2 will remain
blank. The buffer is a first in-first out (FIFO) buffer with 10
locations. Thus, location 2 would remain blank until enough new
definitions had been made to overwrite location 1.
Option 3 will show what plots are in the buffer. Option 4 will result in
a prompt requesting the plot number to display. Entering a plot buffer
number will result in the display of that plot. Option 5 will
immediately generate a plot using all the definitions in the buffer.
Option 6 will prompt for a filename. The plot definitions will be stored
in this file for later use. At this time, any holes in the buffer will
be deleted.
Option 7 will return you to the main menu.
WARNING...Plot does not check the dimension of an array when plotting
from the buffer or from a saved definition file. It is your
responsibility to ensure that the array and the definitions in the saved
file are compatible. If they are not, there is an excellent chance that
you will crash and burn. For instance, do not define a plot for a 50 by
50 array, then try to plot a 10 by 10 array using that definition. This
is guaranteed to get you in trouble.
3.0 3-D Plots
Upon choosing main menu option 1, you will be presented with the 3-D plot
menu. This menu says:
PLEASE CHOOSE AN OPTION:
1 CHOOSE PLOT LABELS
2 CHOOSE PLOT VALUES
3 CHOOSE VIEWER PERSPECTIVE
4 CHOOSE HIDDEN LINE OPTIONS
5 CHOOSE PLOT COLOR
6 CHOOSE PLOT SIZE
7 DO THE PLOT
8 END THE CURRENT PLOT
9 EXIT 3-D PLOT
If you choose, you may immediately select option 7 (do the plot) because
all necessary values for the plot have defaults.
Option 1 will ask you to enter strings for the x axis label, the y axis
label, the z axis label, and the size (cm) of the characters in the
labels. The default is to have no labels.
Option 2 will prompt you for x and y limits, and x/z and y/z ratios. The
ratios will affect how the plot will appear on the screen. The values
default to "good" numbers: the ratios default to 1:1. I suggest you play
around to see what works best for you.
Option 3 will prompt you to enter a perspective in R, theta, and phi
values. Again, experiment. The default places you 45 degrees off the x
axis and 30 degrees above the x y plane.
Option 4 will provide a small menu of hidden line options. It is fairly
self explanatory. The default is no hidden line removal.
Option 5 sets the pen color of the plot
Option 6 prompts you to enter the space on the screen that the plot is to
occupy, in fractions of the total screen size. You are first asked for
the origin of the plot (lower left hand corner) on the screen X axis as a
fraction of the x axis size. Thus, to start the plot midway across the
screen, you would enter 0.5. To start the plot at the left of the
screen, you would enter 0. Similarly, for the Y-axis origin, 0 starts
the plot at the bottom of the screen and .5 starts it midway up. You are
then prompted to enter the fraction of each screen axis that the plot is
to occupy. Again, enter a positive decimal number. Please note that if
the fraction of the axis defining the start point plus the fraction to be
occupied by the plot is greater than 1, there will be clipping of the
plot. Example: to place a plot in the lower left quarter of the screen,
the x origin is 0, the y origin is 0, the x fraction is .5, and the y
fraction is .5. To place the plot in the upper right quarter, the x and
y origins are both .5 and the x and y fractions are also .5. The default
values generate a full screen plot. Note: the routine that handles
keyboard input for Matlab Plot is not very smart. It will accept
non-numeric input from you and happily convert it to a number. This
leads to unpredictable results.
Option 7 will immediately display the plot using the current options.
Option 8 will hang the program until you click on the plot close gadget.
Option 9 returns to the main menu.
4.0 X-Y Plots
This is the most complicated plot option. When you choose main menu
option 2, you will encounter a small option menu which says:
PLEASE CHOOSE THE X-Y PLOT MODE
1 IMPLICIT X, EXPLICIT Y
2 EXPLICIT X, EXPLICIT Y
There are
two types of x-y plotting available to you. In option 1, it is assumed
that each cell in the matrix contains a y value and the x values are
given by the position of the cell in the array. By default, cell
location 1 will be assigned the value x=1, location 2 gets x=2, and so
forth. This is similar to the 3-D plot, but the plot will be 2
dimensional instead of 3-D. You might use this option if you had made a
3D plot of an array and wanted to also plot specific row or column slices
out of the array. As an example, if you are plotting along Rows in
Matrix X which is an M by N array, then if you plot along row M1 such
that 1 > M1 < M, then the location X(M1,1) contains Y1 and the
corresponding x value is assigned the value of 1. Location X(M1,2)
contains Y2 and is assigned x=2, and so forth up to X(M1,N) which
contains YN and is assigned x=N.
In option 2, it is assumed that the data in the array is arranged in
ordered pairs, with a Y value in a cell corresponding to an x value in
another cell. You may have an array with one row containing the x values
and all other rows containing y values that correspond to the x value in
the x row at the same column location. The minimum array dimension for
this option is 2 by N or M by 2 because this option requires ordered
pairs. Again as an example, if you are plotting X(M,N) along rows such
that X(1,N) contains all x values, and X(2,N) contains corresponding Y
values, then you would select option 2. The array could be arranged so
that X(3,N) contains new x values, and X(4,N) contains the corresponding
Y values, X(5,N) contains x, X(6,N) the corresponding Y, and so forth.
You must have at least one set of x and one set of y values, but you may
have as many of each as you choose, arranged in any fashion you see fit.
After choosing one option or the other, you will be informed that you are
plotting from an M row by N column array (M and N given as the
appropriate numbers) and you are asked whether to plot along rows or
columns. In other words, tell Plot how you want the data organized.
Choosing rows will result in a plot of successive column locations in the
same row. Choosing columns will result in a plot of successive row
locations in the same column.
After choosing rows or columns, you will be asked how many lines will be
placed on the plot. You may plot from one to ten sets of ordered pairs,
or Y values if the implicit x option was chosen.
After choosing the number of lines, you will be prompted to enter the row
(or column) number of the x and y components of each line. If the
implicit x option was chosen, you will be prompted for y components only.
You may choose the same row (or column) as many times as you wish.
After entering this information, you will finally reach the main menu.
This menu says:
PLEASE CHOOSE AN OPTION:
1 SELECT THE TYPES OF PLOT AXES
2 SELECT THE X AND Y GRID MARKINGS
3 SELECT THE X AND Y AXIS TICK MARK OPTIONS
4 SELECT THE LINE OPTIONS
5 SELECT THE PLOT COLORS
6 SELECT THE BACKGROUND COLOR
7 SELECT THE AXIS SCALES
8 CHOOSE THE PLOT SIZE
9 CHOOSE THE PLOT LABELS
10 DO THE PLOT
11 END THE CURRENT PLOT
12 EXIT XYPLOT
At this point, sufficient information to do a plot has been provided, and
you may immediately choose option 10 if you wish.
Choosing option 1 will result in another menu giving various log and
linear options which are self explanatory. You may also choose to place
a second Y axis on the right side of the plot. If you choose that
option, another menu will appear with appropriate choices for that axis.
Option 2 will result in a menu to determine the types of grid markings to
be applied.
Option 3 will let you choose axis tick mark options. These options are
cumulative. You should not choose any options for a second y axis tick
marks if you have previously chosen a second y axis from the axis menu.
Option 4 leads through successive menus to determine line and symbol
types and sizes. Four line types are available and four symbols are
available. You may also choose the symbol spacing (ie every data point,
every third data point, etc.) When choosing symbol size, enter your
values in centimeters, or fractions thereof.
Option 5 enables you to set the color of any or all of the plot lines, by
pen number.
Option 6 lets you set the background color for the plot.
Option 7 lets you set the axis scales if for some reason the default
values, which are selected so that all your data will plot on screen, are
not acceptable. When choosing the Implicit X option, if you do not
change the x-axis scale, the plot will be labeled starting with x=1 and
going to x=M or N.
Option 8 lets you choose the plot size in the same fashion as the 3-D
plot. If you use a plot title label, you must leave room for it at the
top of the plot. This means that you should set the y axis size somewhat
shorter than if there was no title. How much shorter depends upon the
size of the title.
Option 9 lets you select plot labels for the x axis, the y axis, the
second y axis, and the plot title. You do not have to select the label
size on this plot; that feature defaults to auto-sizing. However, you
may choose the size if you wish.
Option 10 will immediately do the plot using the selected options.
Option 11 hangs the program until the plot close gadget is selected.
Option 12 returns to the main menu.
5.0 Polar Plots
This release of Matlab supports a complete polar plotting function.
Selecting main menu option 3 will get you there.
When you enter the polar plot function, you are immediately asked to
define the plot mode. You have two choices: R-Theta (type real) mode, in
which case the data in the array is arranged as ordered pairs of
radial-angle information; or X+IY (Complex) mode, in which the data in
the array contains imaginary components. After choosing a mode, you are
given a display similar to that in the XYPLOT routine, asking you to
choose plotting along rows or columns. Pick one. You are then asked how
many data lines to plot. You may choose up to 10 on one plot. If you
chose the R-Theta plot option, you will then be prompted, for each line
to be plotted, to enter the R and Theta row or column numbers. If you
chose complex plots, you will be prompted to enter the row or column
number of the complex number data to be plotted. Then you reach the main
menu.
This menu says:
PLEASE CHOOSE AN OPTION
1 DEFINE THE PLOT LABEL
2 CHOOSE PLOT AXIS TYPE
3 CHOOSE LINE OPTIONS
4 CHOOSE PLOT AXIS AND TICK MARK OPTIONS
5 CHOOSE THE BACKGROUND COLOR
6 CHOOSE THE PLOT COLOR
7 CHOOSE THE PLOT SIZE
8 DO THE PLOT
9 END THE CURRENT PLOT
10 EXIT POLAR PLOTS.
Option 1 enables you to define a plot label.
Option 2 lets you choose among the alternative radius types. Two choices
are available. LINEAR does the plot with a linear radius. LOGARITHMIC
does the plot with a logarithmic radius scale.
Option 3 lets you choose data line options.
Option 4 defines plot axis/tick mark options. You may choose the number
of range rings to draw, and the line styles to use when drawing them.
The number of range rings to be drawn is the total number of range rings
if you are in the linear radius mode, or the number of range rings per
decade in logarithmic radius mode.
Option 5 lets you set the background color. This does a SetRast() and
will wipe out any other plots which are currently displayed. Those plots
remain defined in the plot buffer, however.
Option 6 lets you choose the color of the axis, range rings, and labels
Option 7 lets you choose the size of the plot. An improper selection of
aspect ratio here will result in a distorted graph. The polar plotting
routine won't correct aspect ratio.
Option 8 does the plot. You may select this option as soon as you reach
the main menu.
Option 9 hangs the program until you click on the close gadget.
Option 10 returns to the main plot menu.
6.0 Contour Plots
When you enter the Contour plot function, you immediately encounter the
main menu. It presents the following display:
PLEASE SELECT AN OPTION:
1 CHOOSE PLOT LABELS
2 CHOOSE PLOT VALUES
3 CHOOSE NUMBER OF CONTOURS
4 CHOOSE CONTOUR LEVELS
5 SET THE BACKGROUND COLOR
6 CHOOSE PLOT COLOR
7 CHOOSE PLOT SIZE
8 DO THE PLOT
9 END THE CURRENT PLOT
10 EXIT CONTOUR PLOTS
Option 1 enables you to define x and y axis labels for the plot.
Option 2 enables you to define the minimum and maximum x and y values to
be displayed on the plot. By default, this is an implicit value and
ranges from X=0, Y=0 to X=M,Y=N where the input array is dimensioned M by
N. Choose this option if the default is not acceptable.
Option 3 enables you to choose the number of contour lines to be plotted.
The default is 20 contours.
Option 4 enables you to choose at what values contour lines will be
drawn. By default, they are drawn at equal intervals in the data. This
option enables the user to force contour drawing at specified data
values.
Option 5 enables you to set the background color. This does a SetRast()
and therefore obliterates all other plots currently being displayed. The
plot definitions remain in the plot buffer.
Option 6 lets you choose the color of the plot.
Option 7 lets you define the size of the plot on the screen.
Option 8 draws the picture immediately. You may select this option as
soon as you reach the main menu.
Option 9 hangs the program until you click on the window close box.
Option 10 returns to the main menu.
7.0 Histograms
The histogram function is relatively immature. In the June 20 release,
what is here works, but you may find it too limiting for many
applications. Try it, if it's useful to you, use it.
Upon selecting option 5 on the main menu, you will encounter the
histogram main menu:
PLEASE SELECT AN OPTION:
1 CHOOSE THE BAR GRAPH TYPE
2 CHOOSE BAR GRAPH AXIS TYPE
3 CHOOSE BAR GRAPH AXIS COLORS
4 CHOOSE BAR GRAPH LABELS
5 SET THE BAR GRAPH COLORS
6 SET THE BACKGROUND COLOR
7 SET THE PLOT SIZE
8 DO THE PLOT
9 END THE CURRENT PLOT
10 EXIT TO MAIN MENU
You may immediately choose option 8 if you desire; all necessary values
default. The histogram is somewhat more limited in options than the x-y
plot. You do not get to choose whether to plot columns or rows;
histograms are done along rows only. Furthermore, the first 8 rows of
the array will be histogrammed, one histogram per row, with axis scales
set to include all histograms. If there are fewer than 8 rows, then only
that many rows will be histogrammed. Thus, to get one histogram, you
must input a 1 by N array, with N less than or equal to 512.
Option 1 allows you to choose the histogram type. Two types are
available: statistical and occurence count. In Statistical (the default)
the histogram will be normalized to one. Thus, the maximum possible
value on the y axis is 1, if all events fall into the same bin. This is
for use in statistical distributions.
In Occurence Count, the histogram is not normalized. The Y axis will
reflect the number of events in each cell.
All other Histogram features work as described in previous sections.
8.0 Using Matlab as a data plotter
I have been asked how you do this. Really it is quite simple. I presume
you have an ASCII data file which represents your data, in an appropriate
format. To bring it into Matlab, you must edit the data file to place
the data in a format that Matlab will recognize, then EXECute the file
from within Matlab. For instance, suppose you have the following data
pairs that represent data you have collected/generated. This data
represents X-Y ordered pairs:
***start of dummy ASCII file***
x y
3 2
5 6
47.5 13.2
***end of dummy ASCII file***
You would edit the file and remove all extraneous stuff, such as the
header, the footer, and the x and y labels. You would take the data and
re-format it like this:
x = <
3 2;
5 6;
47.5 13.2;
>
Then, from within matlab, type:
EXEC('MYDATAFILE')
You have just entered a generalized ASCII data file into Matlab and may
plot it as you choose.
9.0 Demos
A demonstration of the plot features is provided on the distribution
disk. The demo will take a previously calculated 2 dimensional Sinc
function (sin(x)/x * sin(y)/y) and plot it 3 ways. To run the demo, at
the CLI prompt CD to the disk containing Matlab. Increase your stack to
100000.
Enter "Matlab" (You should not enter the double quotes)
When the Matlab intro is complete and the Matlab prompt ( <> ) appears,
enter:
"Load('sinc.sav')"
After the load operation is complete, enter:
"Plot(z);"
when asked if the stack is set to 90K, enter:
"Y" (unless, of course, you didn't set the stack)
You now reach the main menu.
Choose option 8. When prompted for a file name, enter:
"sinc2.plt" (do not enter the quotes, just the name)
Now click to the back screen and watch the plotting happen. It will take
about 45 seconds to begin; the 3-D plot has been selected with hidden
line removal activated and that takes some calculation.
You may also start Matlab from Workbench. After starting it from
Workbench, you must load and plot the demo files as described above.
You may execute the script file testit2.exe to see an example of plotting
from batch mode.
Other demo files may be on the disk: those labeled with the suffix .exe
are script files for Matlab which will cause calculations (sometimes
lengthy) to occur, those with the suffix .sav are saved variables which
may be directly plotted after being loaded, and those labeled .plt are
plot definition files. There is nothing magic about these suffixes; I
simply use them to keep track of things. I suggest that you do to.